package top.v5it.japi.ddd.core.dao.impl;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * 排序
 *
 * @author zhanpu
 * @date 2023/3/16
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class Order {

    private final String column;
    private String order;

    public static Order asc(String column) {
        return new Order(column).setOrder(SqlKeyword.ASC.getKeyword());
    }

    public static Order desc(String column) {
        return new Order(column).setOrder(SqlKeyword.DESC.getKeyword());
    }

    @Override
    public String toString() {
        return String.format("`%s` %s", column, order);
    }
}
